export function getSelectDate (e, selectBetween) {
    let selectDate
    const time = new Date()
    const nowYear = time.getFullYear()

    if (selectBetween === 'single') {
        if (nowYear === e.year) { // 选择的今年的日期
            selectDate = e.month + '月' + e.day + '日'
        } else {
            selectDate = e.year + '年' + e.month + '月' + e.day + '日'
        }
        const ParamsDates = {
            selectDate: selectDate,
            selectDay: e.selectDay,
            startTime: e.selectDay,
            endTime: e.selectDay
        }
        return ParamsDates
    } else if (selectBetween === 'multiple') {
        var startTimeArr = dislodgeZero(e.startTime).split('-')
        var endTimeArr = dislodgeZero(e.endTime).split('-')
        console.log(startTimeArr, endTimeArr, 'st数组')

        if (e.startTime.slice(0, 4) === e.endTime.slice(0, 4) && Number(e.startTime.slice(0, 4)) === nowYear) { // 同年份 且与现在年份相同
            if (e.startTime.slice(5, -3) === e.endTime.slice(5, -3)) { // 同月份
                selectDate = startTimeArr[1] + '月' + startTimeArr[2] + '日~' + endTimeArr[2] + '日'
            } else { // 不同月份
                selectDate = startTimeArr[1] + '月' + startTimeArr[2] + '日~' + endTimeArr[1] + '月' + endTimeArr[2] + '日'
            }
        } else { // 与现在年份不相同
            selectDate = e.startTime.slice(0, 4) + '年' + startTimeArr[1] + '月' + startTimeArr[2] + '日~' + e.endTime.slice(0, 4) + '年' + endTimeArr[1] + '月' + endTimeArr[2] + '日'
        }
        const ParamsDates = {
            selectDate: selectDate,
            selectDay: e.startTime,
            startTime: e.startTime,
            endTime: e.endTime
        }
        return ParamsDates
    } else {
        console.log(nowYear, 'nowYear')
        if (nowYear === e.year) { // 选择的是今年的月份
            selectDate = e.month + '月'
        } else {
            selectDate = e.year + '年' + e.month + '月'
        }
        const ParamsDates = {
            selectDate: selectDate,
            selectDay: e.startTime,
            startTime: e.startTime,
            endTime: e.endTime
        }
        return ParamsDates
    }
}
// 去除0 参数 日期 如 2020-07-08 返回为 2020-7-8
// s="abcdefghij"，则s[1]="b"，s[9]="j"
function dislodgeZero (str) {
    let strArray = str.split('-')
    strArray = strArray.map(function (val) {
        if (val[0] === '0') {
            return (val = val.slice(1))
        } else {
            return val
        }
    })
    return strArray.join('-')
}
